﻿using System;
using System.Collections.Generic;
using System.Net;
using Provausio.Server.Nzb.Poller.Object.Client;

namespace Provausio.Server.Nzb.Poller.Data.Source
{
    public class SickbeardPingSource : PingApiOperationBase
    {
        protected override string ApiUri
        {
            get { return Config["SickBeardUri"]; }
        }

        protected override string ApiFormat
        {
            get { return string.Format("api/{0}", Config["SickBeardApiKey"]); }
        }
        
        public SickbeardPingSource() 
            : base("Sickbeard")
        {
            ServiceName = "Sickbeard";
            Parameters.Add(new KeyValuePair<string, object>("cmd","sb.ping"));
            Parameters.Add(new KeyValuePair<string, object>("debug", 1));
        }

        public override bool IsAlive()
        {
            var result = MakeCall<SickbeardPingResponse>();
            return result != null && result.StatusCode == HttpStatusCode.OK;
        }
        
    }
}
